#include "StdAfx.h"
#include "UIButton.h"

namespace DirectUI
{
	CUIButton::CUIButton(void)
		: m_bPressed(false)
		, m_bHover(false)
	{
	}

	CUIButton::~CUIButton(void)
	{
	}

	void CUIButton::PreviewMouseMove( IMouseEventArgs* lpArgs )
	{
		int a = 0;
	}

	void CUIButton::MouseMove( IMouseEventArgs* lpArgs )
	{

	}

	void CUIButton::PreviewLButtonDown( IMouseEventArgs* lpArgs )
	{

	}

	void CUIButton::LButtonDown( IMouseEventArgs* lpArgs )
	{

	}

	void CUIButton::PreviewLButtonUp( IMouseEventArgs* lpArgs )
	{

	}

	void CUIButton::LButtonUp( IMouseEventArgs* lpArgs )
	{

	}

	void CUIButton::MouseEnter( IMouseEventArgs* lpArgs )
	{
		bool bChanged = !m_bHover;
		m_bHover = true;
		if ( bChanged )
		{
			if ( ot_Button == this->GetObjType() )
			{
				CString szName = this->GetProperty(UIPropertyName::Name)->GetStringValue();
				if ( szName.CompareNoCase(L"TestBtn2") == 0 )
				{
					DBGOUT((_T("DirectUI. MouseEnter\n")));
				}
			}
			GetUICore()->GetUIVisualStateManager()->GoToState(this, BTN_HOVER_STATE);
		}
	}

	void CUIButton::MouseLeave( IMouseEventArgs* lpArgs )
	{
		bool bChanged = m_bHover;
		m_bHover = false;
		if ( bChanged )
		{
			if ( ot_Button == this->GetObjType() )
			{
				CString szName = this->GetProperty(UIPropertyName::Name)->GetStringValue();
				if ( szName.CompareNoCase(L"TestBtn2") == 0 )
				{
					DBGOUT((_T("DirectUI. MouseLeave\n")));
				}
			}
			GetUICore()->GetUIVisualStateManager()->GoToState(this, BTN_NORMAL_STATE);
		}
	}

};